import request from '@/utils/request'

/**
 *查询竣工验收列表
 * @param query
 * @param page
 */
export function getTableListApi(query,page) {
  const data = Object.assign(query,page);
  return request({
    url: '/complete-info/list',
    method: 'POST',
    data,
  })
}


// 厂区字典查询
export function getDemandList(query) {
  return request({
    url: `/pigfarm-project-demand/list`,
    method: 'post',
    data: {
      projectId:query
    }
  })
}

// 厂区字典查询
export function getDictList(query) {
  return request({
    url: `/sys-dict/list?type=area`,
    method: 'post',
    data: {
    }
  })
}

/**
 *查询项目
 * @param projectName
 */
export function getProjectListApi(projectName) {
  return request({
    url: '/pigfarm-project/like',
    method: 'get',
    params:{
      projectName
    },
  })
}

/**
 *查询合同
 * @param projectId
 * @param contractTitle
 */
export function getContractListApi(projectId,contractTitle) {
  return request({
    url: `/contract-info/like`,
    method: 'get',
    params:{
      projectId,contractTitle
    }
  })
}

/**
 *查询预算流程列表
 * @param type   project:项目流程/design:图纸设计流程/match:承建商匹配流程/budget:预算流程/balance:结算流程
 * @param projectId
 */
export function getBudgetFlowListApi(type,projectId) {
  return request({
    url: `/bpm/bpmDataList`,
    method: 'get',
    params:{
      type,projectId
    }
  })
}


/**
 *查询详情
 * @param id
 */
export function getDetailInfoApi(id) {
  return request({
    url: `/complete-info/getById/${id}`,
    method: 'get',
  })
}

/**
 *暂存 && 编辑
 * @param type 1新增  2修改
 * @param data
 */
export function addAndUpdateApi(type,data) {
  let url = "";
  if(type==='add'){
    url = '/complete-info/add';
  }else if(type==="edit"){
    url = '/complete-info/update';
  }
  return request({
    url,
    method: 'POST',
    data,
  })
}

/**
 *删除
 * @param ids
 */
export function deleteApi(ids) {
  return request({
    url: '/complete-info/delete',
    method: 'POST',
    data:ids,
  })
}

/**
 *查询任务分配按钮权限
 * @param projectId
 * @param contractId
 */
export function getTaskDistributeBtnById(projectId,contractId) {
  return request({
    url: `/balance-info/complete/${projectId}/${contractId}`,
    method: 'get',
  })
}

/**
 *任务分配
 * @param projectId
 * @param contractId
 * @param dealOa
 * @param dealName
 */
export function setTaskDistributeApi(projectId,contractId,dealOa,dealName) {
  return request({
    url: `/complete-info/setJieSuan`,
    method: 'post',
    data:{
      projectId,contractId, dealOa,dealName
    }
  })
}
